﻿using Newtonsoft.Json;
using System;
//using Newtonsoft.Json;

namespace T.FAS.Runtime.Metadata.Entity.DataModel
{
    /// <summary>
    /// 数据查询-数据源
    /// </summary>
    [Serializable]
    public class DataQuerySource : System.ICloneable
    {
        /// <summary>
        /// 主键id
        /// </summary>
        public string ID { get; set; }

        /// <summary>
        /// 数据查询id
        /// </summary>
        public string DataQueryID { get; set; }

        /// <summary>
        /// 数据对象id
        /// </summary>
        public string DataObjectID { get; set; }

        /// <summary>
        /// 别名
        /// </summary>
        public string Alias { get; set; }

        /// <summary>
        /// 是否主查询节点
        /// </summary>
        public bool IsMainSource { get; set; }

        /// <summary>
        /// 数据源类型，默认为DataObject:0，DataAsset:1
        /// </summary>
        public DataQuerySourceType SourceType { get; set; }

        /// <summary>
        /// 数据对象实体
        /// </summary>
        public DataObject DataObject { get; set; }

        /// <summary>
        /// 资产对象实体
        /// </summary>
        //Todo:
        //public DataAsset DataAsset { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        public int Sort { get; set; }

        /// <summary>
        /// 备用字段
        /// </summary>
        [JsonIgnore]
        public string Ext1 { get; set; }

        /// <summary>
        /// 备用字段
        /// </summary>
        [JsonIgnore]
        public string Ext2 { get; set; }

        /// <summary>
        /// 备用字段
        /// </summary>
        [JsonIgnore]
        public string Ext3 { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        //[DataMember]
        [JsonIgnore]
        public string Creator { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>        
        //[DataMember]
        [JsonIgnore]
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 最后修改人
        /// </summary>
        //[DataMember]
        [JsonIgnore]
        public string LastModifier { get; set; }

        /// <summary>
        /// 最后修改时间
        /// </summary>        
        //[DataMember]
        [JsonIgnore]
        public DateTime LastModifyTime { get; set; }

        public object Clone()
        {
            var source = this.MemberwiseClone() as DataQuerySource;

            return source;
        }
    }

    public enum DataQuerySourceType
    {
        DataObject = 0,
        DataAsset = 1,
    }
}
